
const http = require('https');
import SpiderOptions from "../interfaces/SpiderOptions";

export default class Spider{
  options: SpiderOptions
  //接口
     constructor(options: SpiderOptions = {url:"",method:"get"}){
       this.options = options;
       this.start()
     }
     start(){
let req = http.get(this.options.url,{headers:this.options.headers,method:this.options.method},(res:any)=>{
  let chunks :any[] = [];res.on("data",(c:any)=>chunks.push(c));

  res.on("end",()=>{
    let result = Buffer.concat(chunks).toString();console.log(result);
  })
})
     }
}